<template>
<div>
  <my-tree-node 
    v-show="show" 
    :tree="tree" 
    :level.once="level">
  </my-tree-node>
  <my-tree-item 
    v-for="child in tree.childs" 
    :tree="child" 
    :level.once="level + 1" 
    :show="itemShow">
  </my-tree-item>
</div>  
</template>

<script>
import MyTreeNode from './MyTreeNode.vue'

export default {
  name: 'my-tree-item',
  props: {
    tree: {
      type: Object
    },
    level: {
      type: Number,
      default: 0
    },
    show: {
      type: Boolean,
      default: true
    }
  },
  components: {
    'my-tree-node': MyTreeNode
  },
  computed: {
    itemShow () {
      return this.tree.open && this.show
    }
  }
}
</script>

<style>
</style>